<%@page import="dao.UserManager"%>
<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Virtual Intranet Library</title>
</head>
<body>
	<%
		if (request.getParameter("submit") != null) {
			String username = request.getParameter("username");
			String password = request.getParameter("password");
			if (!username.equals("") && !password.equals("")) {
				User user = UserManager.getUser(username, password);
				if (user != null) {
					session.setAttribute("user", user);
					response.sendRedirect("home.jsp");
				}
			}
		}
	%>
	<center>
		<h2>Welcome to the Virtual Intranet Library!</h2>
		<form method="post">
			Username: <input type="text" name="username"><br>
			Password: <input type="password" name="password"><br> <input
				type="submit" name="submit" value="Login"> <a
				href="registration.jsp">Register</a>
		</form>
	</center>
	<%
		if (request.getParameter("submit") != null) {
			out.println("<center><h3>Incorrect username or password!</h3></center>");
		}
	%>
</body>
</html>